package br.inatel.ec203.projeto.view;

import java.awt.Dimension;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;

public class DebitPanel extends JPanel {
	
	private static final long serialVersionUID = 923002402940063216L;
	
	private JLabel amountLabel;
	private JSpinner amountSpinner;

	public DebitPanel() {
		initialize();
	}

	private void initialize() {
		setBorder(configBorder());
		add(getAmountLabel());
		add(getAmountSpinner());
	}

	private Border configBorder() {
		EmptyBorder outsideEmptyBorder = new EmptyBorder(5, 5, 5, 5);
		TitledBorder titledBorder = new TitledBorder("Debitar quantidade de componentes");
		CompoundBorder partialCompoundBorder = new CompoundBorder(outsideEmptyBorder, titledBorder);
		EmptyBorder insideEmptyBorder = new EmptyBorder(5, 5, 5, 5);
		CompoundBorder totalBorder = new CompoundBorder(partialCompoundBorder, insideEmptyBorder);
		
		return totalBorder;
	}

	private JLabel getAmountLabel() {
		if (amountLabel == null) {
			amountLabel = new JLabel();
			amountLabel.setText("Quantidade");
		}
		return amountLabel;
	}

	public JSpinner getAmountSpinner() {
		if (amountSpinner == null) {
			amountSpinner = new JSpinner();
			amountSpinner.setPreferredSize(new Dimension(50, 20));
		}
		return amountSpinner;
	}

}
